<template>
  <div>
    <p>我是子组件</p>
    <p>{{ str }}</p>
    <p>{{ obj }}</p>
    <p>{{ arr }}</p>
    <p>{{ num }}</p>
    <p>{{ sex }}</p>
    <p>{{ name }}</p>
    <button @click="send()">子传父传值</button>
    <br />
    <hr />
    <hr />
    <hr />
    <hr />
    <hr />
    <button @click="send1()">兄弟之间传值</button>
  </div>
</template>

<script>
export default {
  props: {
    str: String,
    obj: Object,
    arr: Array,
    num: {
      type: Number,
      validator: (val) => val > 1,
    },
    sex: {
      type: String,
      // required: true,
    },
    name: {
      type: String,
      default: "Tom",
    },
  },
  data() {
    return {
      msg: "我是子组件我骄傲",
      msg1: "我是兄弟组件我骄傲",
    };
  },
  methods: {
    //函数
    send() {
      //第一个是参数，自定义事件
      this.$emit("getdata", this.msg);
    },
    send1() {
      this.eventbus.$emit("data", this.msg1);
    },
  },
};
</script>

<style>
</style>